#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "ui_mainwindow.h"
#include "getParams.h"
#include "plot.h"
#include "drawsim.h"
#include "master.h"
#include "ethernet.h"

#include <QTimer>
#include <QFileDialog>
#include <QFile>
#include <QTextStream>
#include <QErrorMessage>
#include <QtGui/QMainWindow>


class QTimer;

namespace Ui
{
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();
    Ui::MainWindow *ui;

    SimData *simDataArray[99];
    SimData *simData;

    GetParams *paramsWindow;

    Plot *plotWindow;

    DrawSim *drawSim;

    Enet *myEnet;
    Master *masterArray[99];
    Master *myMaster;

    QString FilePath;
    QFile simFile;

    void process_line(QString );

public slots:

    void ethernetStatus(int );  // prints colisions, updates colisions
    void masterAction(int , int ); //prints master actions, updates received
    void on_paramsButton_clicked();
    void saveParams(int , int , int , int );
    void dontSaveParams();

private:
    QTimer *timer; // for using a loopish thing with a pause between running

    // Single Sim counter
    int SingleSimStep;

    // not used yet
    int frame;

    // Start/Stop flag
    int keepGoing;

    int simCount;


private slots:


    void on_actionExit_triggered();
    void on_actionSave_triggered();
    void on_actionOpen_triggered();
    void on_actionNew_triggered();

    void on_ShowGraphButton_clicked(); // shows graph window
    // emits zoom value signal
    void on_zoomSlider_valueChanged();
    // changes start/stop flag
    void on_StartButton_clicked();
    // picked multi sim ( runs a while loop ) or single sim (starts a timer) and initalizes variables
    void StartSim();
    // Single  sim code, run
    void SingleSimCode();



    //prints to text box
    void trace(QString);

 signals:

    // starts a sim, passes master count, max/min packet size, speed
    void startTheSim(int, int, int, int);

    void stopTheSim(void); // stops a sim

    void drawEnetStatus(int);  // signals the drawer to update ethernet status

    void drawMasterAction(int, int);   // signals the drawer to update master status

    void showSignal(void); // signals the paramsWindow that it is shown

    void zoomChanged(int ); // signals the drawers to change the zoom

    void mastersChanged(int); //signals the drawer that the number of masters has been changed

};

#endif // MAINWINDOW_H
